import { RouteRecordRaw } from "vue-router";
import ROLE_ENUM from "@/access/ROLE_ENUM";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "推荐",
    component: () => import("@/views/article/RecommendView.vue"),
  },
  {
    path: "/article/detail/:articleId",
    name: "文章详情",
    component: () => import("@/views/article/ArticleDetailsView.vue"),
    meta: { access: ROLE_ENUM.USER, hideInMenu: true },
  },
  {
    path: "/questionBank",
    name: "题库",
    component: () => import("@/views/question/ListQuestionView.vue"),
  },
  {
    path: "/question/submit/list",
    name: "题目提交列表",
    component: () => import("@/views/question/ListQuestionSubmitView.vue"),
  },
  {
    path: `/question/doQuestion/:questionId`,
    name: "在线做题",
    component: () => import("@/views/question/DoQuestionView.vue"),
    meta: { access: ROLE_ENUM.USER, hideInMenu: true },
  },
  {
    path: "/question/add",
    name: "创建题目",
    component: () => import("@/views/question/AddQuestionView.vue"),
    meta: { access: ROLE_ENUM.ADMIN },
  },
  {
    path: "/question/update",
    name: "更新题目",
    component: () => import("@/views/question/AddQuestionView.vue"),
    meta: { access: ROLE_ENUM.USER, hideInMenu: true },
  },
  {
    path: "/question/manage",
    name: "题目管理",
    component: () => import("@/views/question/ManageQuestionView.vue"),
    meta: { access: ROLE_ENUM.ADMIN },
  },
  {
    path: "/article/manage",
    name: "文章管理",
    meta: { access: ROLE_ENUM.USER },
    component: () => import("@/views/article/ArticleManageView.vue"),
  },
  {
    path: "/article/add",
    name: "添加文章",
    meta: { access: ROLE_ENUM.USER, hideInMenu: true },
    component: () => import("@/views/article/AddArticleView.vue"),
  },
  {
    path: "/article/update",
    name: "更新文章",
    meta: { access: ROLE_ENUM.USER, hideInMenu: true },
    component: () => import("@/views/article/AddArticleView.vue"),
  },
  {
    path: "/user",
    name: "用户",
    component: () => import("@/layouts/UserLayout.vue"),
    children: [
      {
        path: "/user/login",
        name: "用户登录",
        component: () => import("@/views/user/UserLoginView.vue"),
      },
      {
        path: "/user/register",
        name: "用户注册",
        component: () => import("@/views/user/UserRegisterView.vue"),
      },
    ],
    meta: { hideInMenu: true },
  },
  {
    path: "/manage/user",
    name: "用户管理",
    meta: { access: ROLE_ENUM.ADMIN },
    component: () => import("@/views/user/UserManageView.vue"),
  },
  {
    path: "/leaderboard",
    name: "排行榜",
    component: () => import("@/views/LeaderboardView.vue"),
  },
  {
    path: "/statistics",
    name: "统计",
    meta: { access: ROLE_ENUM.ADMIN },
    component: () => import("@/views/StatisticsView.vue"),
  },
  {
    path: "/about",
    name: "关于",
    component: () => import("@/views/AboutView.vue"),
  },
  {
    path: "/noAuth",
    name: "无权访问",
    meta: { hideInMenu: true },
    component: () => import("@/views/NoAuthView.vue"),
  },
];
